<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="line">
  <link rel="stylesheet" href="./assets/common.css">
  <title>Line Plot</title>
  <style>
      body{background-color: #ebf0f0}
  </style>
</head>

<body>
  <div id="canvas"></div>
  <script src="./assets/jquery-3.2.1.min.js"></script>
  <script src="../build/g2.js"></script>
  <script>
    const colors = [ '#1f9399', '#dcb17f', '#875630', '#fd9833', '#254297', '#d872be', '#185c75', '#52c09c', '#766d58', '#28b8bd', '#f5d08e', '#b68761', '#f69574' ];
    $.getJSON('./data/fertility.json', data => {
      const chart = new G2.Chart({
        container: 'canvas',
        forceFit: true,
        height: window.innerHeight,
        padding: [ 10, 200, 50, 50 ]
      });
      chart.source(data);
      chart.legend({ attachLast: true });
      chart.line().position('year*value').color('country', colors)
            .size('country', country => {
              if (country === 'China') return 5;
              return 2;
            })
            .opacity('country', country => {
              if (country === 'China') return 1;
              return 0.6;
            })
            .style({ lineCap: 'round' });
      chart.render();
    
    });
  </script>
</body>

</html>